home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / ABox 1.9.5 / CPlus Files / ABUEnv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-26  |  5.7 KB  |  244 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABUEnv.c
  15.  
  16. NAME
  17.     ABUEnv.c, part of the ABox project source code,
  18.     responsible for mix-in handling the AboutBox environment stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                ttempel@monmouth.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <ttempel@monmouth.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     10 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  38.                             release and the associated Universal Headers from Apple:
  39.                             most methods that returned references now have "Ref" at
  40.                             the end of their methods names to prevent possible collisions
  41.                             with datatypes and classes of the same name (older versions
  42.                             of the compiler didn't have a problem with this).
  43.     25-oct-95    -    ty    -    changes for "const" usage under CW7; simplification of Boolean
  44.                             query methods
  45.  
  46. */
  47.  
  48. /*===========================================================================*/
  49.  
  50. /*======= Segmentation directives ========*/
  51.  
  52. #ifdef USE_MANUAL_SEGMENTATION
  53. #pragma segment ty
  54. #endif
  55.  
  56. /*============ Header files ==============*/
  57.     
  58. #include     "ABUEnv.h"
  59.  
  60. /*=============== Globals ================*/
  61.  
  62. /*================ CODE ==================*/
  63.  
  64.  
  65. /*=============================== ABUEnv::ABUEnv ================================*/
  66. ABUEnv::ABUEnv(void)
  67. {
  68.     mCheckedRef = false;
  69.     mIndicator = false;
  70.     mResult = 0;
  71. }    // end ABUEnv
  72.  
  73.  
  74. /*=============================== ABUEnv::~ABUEnv ================================*/
  75. ABUEnv::~ABUEnv(void)
  76. {
  77.     // Close();
  78. }    // end ~ABUEnv
  79.  
  80.  
  81.  
  82. /*=============================== ABUEnv::CheckGestalt ================================*/
  83. OSErr
  84. ABUEnv::CheckGestalt(OSType inGestaltSelector)
  85. {
  86.     OSErr anError = noErr;
  87.     
  88.     if (!this->WasChecked())
  89.     {
  90.         long theResult = 0;
  91.         this->CheckedRef() = true;
  92.         if (this->GestaltAvailable())
  93.         {
  94.             anError = ::Gestalt(inGestaltSelector, &theResult);
  95.             this->SetResult(theResult);
  96.         } else {
  97.             anError = paramErr;
  98.         }
  99.     } // end if block
  100.     return anError;
  101. }    // end CheckGestalt
  102.  
  103.  
  104.  
  105. /*=============================== ABUEnv::IsPresent ================================*/
  106. Boolean    ABUEnv::IsPresent(void)
  107. {
  108.     //    OVERRIDE THIS FUNCTION!
  109.     return false;
  110. }    // end IsPresent
  111.  
  112.  
  113.  
  114. /*=============================== ABUEnv::Feature ================================*/
  115. Boolean    ABUEnv::Feature(long mask)
  116. {
  117.     Boolean theAnswer = this->GetResult() & mask;
  118.     return theAnswer;
  119. }    // end Feature
  120.  
  121.  
  122. /*=============================== ABUEnv::Attribute ================================*/
  123. Boolean    ABUEnv::Attribute(short inBitToTest)
  124. {
  125.     return (((this->GetResult() >> inBitToTest) & 1) != 0);
  126.  
  127. }    // end Attribute
  128.  
  129.  
  130. /*=============================== ABUEnv::Initialize ================================*/
  131. OSErr    ABUEnv::Initialize(void)
  132. {
  133.     //    OVERRIDE THIS FUNCTION!
  134.     return noErr;
  135.  
  136. }    // end Initialize
  137.  
  138.  
  139.  
  140. /*=============================== ABUEnv::Close ================================*/
  141. OSErr    ABUEnv::Close(void)
  142. {
  143.     //    OVERRIDE THIS FUNCTION!
  144.     //CleanUp();
  145.     //
  146.     //    generally, you should shut down any environment stuff here
  147.     return noErr;
  148.  
  149. }    // end Close
  150.  
  151.  
  152. /*=============================== ABUEnv::CleanUp ================================*/
  153. void    ABUEnv::CleanUp(void)
  154. {
  155.     //    OVERRIDE THIS FUNCTION!
  156.     //
  157.     //    generally, you should release memory here
  158.     return;
  159.  
  160. }    // end CleanUp
  161.  
  162.  
  163.  
  164. /*=============================== ABUEnv::Begin ================================*/
  165. OSErr    ABUEnv::Begin(void)
  166. {
  167.     //    OVERRIDE THIS FUNCTION!
  168.     return noErr;
  169.  
  170. }    // end Begin
  171.  
  172.  
  173.  
  174. /*=============================== ABUEnv::End ================================*/
  175. OSErr    ABUEnv::End(void)
  176. {
  177.     //    OVERRIDE THIS FUNCTION!
  178.     return noErr;
  179.  
  180. }    // end End
  181.  
  182.  
  183.  
  184. /*=============================== Gestalt Stuff ================================*/
  185. //
  186. //  These routines, from Inside Macintosh sample code, determine whether
  187. //    the Gestalt function is available on the current system.
  188.  
  189.  
  190. /*=============================== ABUEnv::GestaltAvailable ================================*/
  191. Boolean ABUEnv::GestaltAvailable(void)
  192. {
  193.     const    gestaltTrap = 0xA1AD;
  194.     return ABUEnv::TrapAvailable(gestaltTrap);
  195. }    // end ABUEnv::GestaltAvailable
  196.  
  197.  
  198.  
  199. /*=============================== ABUEnv::TrapAvailable ================================*/
  200. Boolean    ABUEnv::TrapAvailable(short theTrap)
  201. {
  202.     TrapType     tType;
  203.     Boolean        result;
  204.     
  205.     tType = ABUEnv::GetTrapType(theTrap);
  206.     if(tType == ToolTrap)
  207.     {
  208.         theTrap = ::BitAnd(theTrap, 0x07FF);
  209.         if(theTrap >= NumToolboxTraps())
  210.             theTrap = _Unimplemented;
  211.     }
  212.     result = (::NGetTrapAddress(theTrap, tType) != 
  213.               ::NGetTrapAddress(_Unimplemented, ToolTrap));
  214.     return result;
  215. }    // end TrapAvailable
  216.  
  217.  
  218.  
  219. /*=============================== ABUEnv::NumToolboxTraps ================================*/
  220. short ABUEnv::NumToolboxTraps(void)
  221. {
  222.     if(::NGetTrapAddress(_InitGraf, ToolTrap) == ::NGetTrapAddress(0xAA6E, ToolTrap))
  223.         return 0x0200;
  224.     else
  225.         return 0x0400;
  226. }    // end NumToolboxTraps
  227.  
  228.  
  229.  
  230. /*=============================== ABUEnv::GetTrapType ================================*/
  231. TrapType ABUEnv::GetTrapType(short theTrap)
  232. {
  233.     const trapMask = 0x0800;
  234.     
  235.     if(::BitAnd(theTrap, trapMask) > 0)
  236.         return ToolTrap;
  237.     else
  238.         return OSTrap;
  239. }    // end GetTrapType
  240.  
  241.  
  242.  
  243.  
  244.